<?php
error_reporting(0);
$isadmin=1; 
include_once '../../comm/config.php';
include_once '../include/page.class.php';
include_once '../../comm/checkpostandget.php';
//调用商铺类型
$shopTypeSql = "SELECT * FROM ".$BIAOTOU."shoptype ";
$shopTypeRes = mysql_query($shopTypeSql);
//

$shopUnionSql ="SELECT a.*,b.authtype,b.conditions,b.license,c.typename,b.authtime,b.authallowed FROM ".$BIAOTOU."usershop as a,".$BIAOTOU."shopauth as b , ".$BIAOTOU."shoptype as c
WHERE a.username = b.username and b.authtype = c.id and b.authallowed = 0";
$shopUnionRes = mysql_query($shopUnionSql);

$px=$_GET['px'];//排序
if($px=="")$px=2;

$fxb=$_GET['fxb'];
if($fxb==1) $where_fxb=' and fxb=1';
else $where_fxb='';

$where="";
$page_url="certificate.php?px=".$px;
$where = "where ".$where;

$page = !($_GET['page'])?'1':intval($_GET['page']);
$pagesize=5;
$page2=($page-1)*$pagesize;
if($where!='') $where=$where.$where_fxb;

if($px=="1"){$where=$where." order by regtime  desc,id desc";}
if($px=="0"){$where=$where." order by regtime  asc,id desc";}
if($px=="2"){$where=$where." order by id desc";}
//用于查询
$sql="select * from ".$BIAOTOU."usershop $where";
$rs = mysql_query($sql);
$total = mysql_num_rows($rs)?mysql_num_rows($rs):0;	
//用于分页
$sql="select * from ".$BIAOTOU."usershop $where limit $page2,$pagesize";
$rs = mysql_query($sql);

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="../js/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理中心</title>
<link href="../css/style.css" rel="stylesheet" type="text/css"></head>

<body topmargin="5" leftmargin="0">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="282" valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>
          <table cellspacing="0" width="100%" height="207" style="border:1px  solid #DCEAF7;">
            <tr>
            <td width="300" height="30" bgcolor="E9F2FB" class="bigtext"><strong>&nbsp;<img src="../images/arrow.gif" width="16" height="22" align="absmiddle" /> 商户认证管理</strong>&nbsp;&nbsp;&nbsp;&nbsp;<a href="authtype.php">认证类别管理</a></td> 
              <form id="form1" name="form1" method="get" action="">
              <td width="580" height="30" bgcolor="E9F2FB" class="bigtext">
                <label>
			    <?php 
			    	$gametype=$_GET['type'];
			    	while($type = mysql_fetch_array($shopTypeRes)){
			    		if(in_array($type['id'],$gametype)){
			    			echo "<input checked name='type[]' type='checkbox' value='{$type['id']}' class='FLeft check' align='middle'><span class='FLeft'>{$type['typename']}</span>";
			    		}else{
			    			echo "<input name='type[]' type='checkbox' value='{$type['id']}' class='FLeft check' align='middle'><span class='FLeft'>{$type['typename']}</span>";
			    		}
			    		
			    	}
			    ?>
                </label>
                <label>
                <select id="usertype" name="usertype">
			    <option <?php echo $a5=($_GET['usertype']=='0')?"selected":"";?> value="0">用户名</option>
			    <option <?php echo $a5=($_GET['usertype']=='1')?"selected":"";?> value="1">店名</option>
			    </select>
               <input type="text" style="width:80px" name="name" value="<?php echo $a6=($_GET['name'])?trim($_GET['name']):"";?>" />
                </label>
                 <?php if($verifying == '0'){?>
             		<input type="hidden"  name="link" value="0"/>
	             <?php }?>
                            <label>
                            <input type="submit" name="Submit" value="查找" />
                            </label>
              </td> </form>
              <td width="150" align="right" bgcolor="E9F2FB" class="bigtext">共有 <b><?php echo $total;?></b> 条记录&nbsp;&nbsp;</td>
            </tr>
            <tr>
              <td colspan="3" valign="top"><table width="100%" height="300" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td valign="top"><table width="100%" border=1 cellpadding=0 cellspacing=0
style="border-collapse: collapse" bordercolor="#dddddd">
                  
                    <tr>
                      <td width="4%" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;ID</strong></td>
                      <td width="10%" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;店名/用户名</strong></td>
                      <td width="10%" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>手机号/网店地址</strong></td>
                      <td width="5%" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;申请类别</strong></td>
                      <td width="30%" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;认证内容</strong></td>
                      <td width="15%" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;申请时间 <?php if($px=="0"){echo "<a href=\"certificate.php?px=1\"><img src='../images/up.gif' title='向上排序'/></a>";}elseif($px=="1"){echo "<a href=\"certificate.php?px=0\"><img src='../images/drop.gif' title='向下排序'/></a>";}else{echo "<a href=\"certificate.php?px=0\"><img src='../images/nochoice.gif' title='未选中'/></a>";}?></strong></td>
                      <td width="10%" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;执行操作</strong></td>
                    </tr>
					<?php
					$i = 1;
					while ($row = mysql_fetch_array($shopUnionRes))
					{
						echo "<tr>";
                      	echo "<td align=center height=30 class=bigtext>&nbsp;".$i."</td>";
                      	echo "<td align=center height=30 class=bigtext>&nbsp;".$row["ddshopname"]."|<br>".$row["username"]."</td>";
                      	echo "<td align=center height=30 class=bigtext>&nbsp;".$row["contact_mobile"]."|<br>".$row["url"]."</td>";
						echo "<td align=center class=bigtext>&nbsp;".$row["typename"]."</td>";
						if($row["license"] == ""){
							echo "<td align=center class=bigtext>&nbsp;".$row["conditions"]."<br></td>";
						}else{
							echo "<td align=center class=bigtext>&nbsp;".$row["conditions"]."<br><img src='../images/shopauth/".$row["license"]."'></td>";
						}
						echo "<td align=center class=bigtext>&nbsp;".$row["authtime"]."</td>";
						echo "<td align=center align=center class=bigtext><a onclick=allowConfirm('".$row["ddshopname"]."','".$shoptype."','".$row["Id"]."'); href=javascript:void(0); class=link4>通过</a> <a href=# class=link4>拒绝</a></td>";
						echo "</tr>";
						$i ++;
					}
					?></table>
					<div class="yahoo2" style=" margin-top:30px;"><?php 
				pageft($total,$pagesize,1,1,0,10,$page_url);
				echo $pagenav;?></div>
					</td>
                </tr>
              </table></td>
            </tr>
          </table></td>
        </tr>
      
    </table></td>
  </tr>
</table>
<script>
function allowConfirm(shopname,type,id){
	 if(confirm("通过'"+shopname+"'的'"+type+"'申请？")){
		 alert("已经通过'"+shopname+"'的'"+type+"'申请");
		 location.href="./certificate.php?link=verfying&action=allow&id="+id;
	 }else{
		 return false;
	 }
	    
}
</script>
</body>
</html>
<?php mysql_close($link);?>
